﻿@model IEnumerable<OrdersDB.Models.OrderInfo>

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>简易订单管理系统</title>
</head>
<body>
    <h1>简易订单管理系统</h1>
    <p>
        @Html.ActionLink("添加订单", "Create")
    </p>
    <div>
        <form action="/" method="get">
            下单人：
            <input type="text" name="key" />
            <input type="submit"  value="搜索" class="btn-primary" @ViewBag.Key/>
        </form>
    </div>
    <table class="table">
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.OrderID)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.UserName)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.OrderDate)

            </th>
            <th>
                @Html.DisplayNameFor(model => model.OrderState)
            </th>
            <th>操作</th>
        </tr>
    
    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.OrderID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UserName)
            </td>
            <td>
                @*时间格式日期*@
                @string.Format("{0:yyyy年MM月dd日}", item.OrderDate)
            </td>
            @*<td style="background-color:red;">
            @Html.DisplayFor(modelItem => item.OrderState)
        </td>*@
            @if (item.OrderState == 0)
            {
                <td style="background-color:red;text-align:center">未发货</td>
            }
            else
            {
                <td>已发货</td>
            }
            <td>
                @if (item.OrderState == 0)
                {<a href="/OrderInfoes/SendOrder/@item.OrderID">发货</a>}

                @Html.ActionLink("删除", "DeleteConfirmed", new { id = item.OrderID },new { onclick="return confirm('确定要删除吗？')"})
            </td>
        </tr>
    }
    
    </table>
</body>
</html>
